/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton, CColumn } from '../../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http } from '../../../../library/func';
import Icon from '../../../../project/style/icon';
import ConfigNet from '../../../../project/func/http/http'

/******************************************************************************************
 * Export Class
 ******************************************************************************************/
export default class Gift extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {
			user: {
				set_img: '20181018/1539869551232t1pl.jpg',
				set_dist_number: ''
			}


		}
	}

	/*------------------------------------------------------------------------------------
	 * 生命周期
	 *-----------------------------------------------------------------------------------*/
	// didMount
	componentDidMount() {
		// 获取类别数据
		ConfigNet.get({
			url: 'usercenter/info.php',
			success: (data)=> {
				this.setState({
					user: data
				})
			},
			error: (res)=> {
				console.log('逻辑错误');
				console.log(res);
			},
		});
	}
	
	/*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
	// onClick
	onClick = (e)=> {
		
	}
    
    // onRedirect
    onRedirect = (url, e)=> {
        wx.redirectTo({
            url: url
        })
    }

    // onNavigate
    onNavigate = (url, e)=> {

    }

	/*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
	config = {
        navigationBarTitleText: '推荐下载',
        navigationBarBackgroundColor: '#fff',
    }
	//复制剪贴板
	copyText = (e) => {

		wx.setClipboardData({
			data: this.state.user.set_dist_number,
			success: function(res) {
			  wx.getClipboardData({
				success: function(res) {
				  console.log(res.data) // data
				}
			  })
			}
		})		  
	}

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/

	render () {

		return (
			<CPage>
				<CContent bg='#fff'>
					
					{/* 推荐下载图片 */}
					{/* <CImage  src='http://image.cdn.hesq.com.cn/rushbuy/product/{{invite.set_img}}'></CImage> */}
					<CCenter h='100' lh='100'>
						<CText size='28'>推荐图示例</CText>
					</CCenter>
					<CRow>
						<Image lazyLoad={true} style='width:400rpx; height:572rpx; margin:0 auto' src='http://image.mod.hesq.com.cn/rushbuy/assets/20181113/invit.jpg' />
					</CRow>

					{/* 邀请码 */}
					<CBetween mt='40' px='60' x='center' >
						{/**/}
						<CHand color='#333' size='32' mr='26'>您的邀请码为 </CHand>
						<CHand color='#333' size='32' bold >{user.set_dist_number} </CHand>
						<CText bg='#f2f2f2' size='24' pa='8 26' ra='40' ml='24' onClick={this.copyText.bind(this)}>复制</CText>
					</CBetween>

					{/* 推荐给好友 */}
					<CImage mt='10' h='20' src='http://image.mod.hesq.com.cn/rushbuy/assets/20181113/product/{{invite.set_img}}'></CImage>

					{/* 微信好友，微信朋友圈 */}
					<Image style='width:750rpx; height:100rpx;' src='http://image.mod.hesq.com.cn/rushbuy/assets/20181113/recommend.jpg' />
					<CAround py='20' px='20'>
						<CItemY x='center'>
							<CImage w='100' h='100' ra='52' ba='1 solid #ddd' src='http://image.mod.hesq.com.cn/rushbuy/assets/20181113/wexin.jpg'></CImage>
							<CText mt='20'>微信好友</CText>
						</CItemY>
						<CItemY x='center'>
							<CImage w='100' h='100' ra='52' ba='1 solid #ddd' src='http://image.mod.hesq.com.cn/rushbuy/assets/20181113/pengyou.jpg'></CImage>
							<CText mt='20'>微信朋友圈</CText>
						</CItemY>
					</CAround>

				</CContent>
			</CPage>
		)
	}
}


